home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.8 KB | 163 lines | [TEXT/ToyS] |
- -- Properties
- property kasName : "Rotate CCW V1.0"
- property kasRotate : -900 -- Back 90 degrees
- property kasPause : 5 -- Time to preview
-
- -- Globals
- global gasInfoWind -- Info window
-
- global gasFoldersToDo -- The folders left to process
- global gasShown -- Number gone!
- global gasDone -- Number checked!
-
-
- on open fsObjs
- -- Set up prefix
- set gasShown to 0
- set gasDone to 0
-
- set gasInfoWind to display info titled kasName message "Starting…" located at {20, 40}
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (basic info for fsObj)
-
- if (the catalog kind of myInfo is a folder) then
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- else
- DoOne(fsObj)
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
- set gasFoldersToDo to edit list gasFoldersToDo with edits {n} with removal of items
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- ShowAction("Done!")
-
- pause for 5 with seconds timing -- Let screen wait...
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
- end open
-
-
- on DoOne(fsObj)
- set imageType to the image type in fsObj
- set fname to (catalog name of (basic info for fsObj))
- set newFile to (fsObj as string) & ".b" & (kasRotate div 10)
-
- ShowFile(fname)
-
- if (imageType is not "") then
- ShowImageType(imageType)
-
- -- Get picture
- try
- set pic to the image from fsObj
- on error errStr number errNum
- ShowError(errStr, errNum)
- end try
-
- -- Rotate it
- set pinf to the picture info for pic
- set pic to rotate image pic by kasRotate
-
- -- Show it
- set showPic to display drawing titled fname starting with pic
-
- -- Save it
- if (picture compressed quality of pinf) is 0 then
- store image pic in newFile as imageType
- else
- store image pic in newFile as imageType ¬
- with percent quality (picture compressed quality of pinf)
- end if
-
- set the icon of newFile to pic
- -- And out
- pause for kasPause with seconds timing
- display drawing showPic with disposal
- else
- ShowFault("No image!")
- end if
- end DoOne
-
-
- on GoDeep(foldObj)
- ShowPath(foldObj)
-
- set daddy to foldObj as string
-
- -- Do kinds that match
- set myItems to the entries in foldObj whose kinds are a file
- set n to the number of items in myItems
- ShowAction("Scanning files (" & n & ")")
-
- repeat with myItem in myItems
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do folders
- ShowAction("Scanning subfolders…")
- set myItems to the entries in foldObj whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
-
- -- Done
- ShowAction("…")
- end GoDeep
-
-
- on ShowPath(pth)
- display info gasInfoWind message "Current Folder: " & (pth as string)
- end ShowPath
-
-
- on ShowFile(fname)
- display info gasInfoWind message fname at line 2
- end ShowFile
-
-
- on ShowImageType(iType)
- display info gasInfoWind message ("Found image type: " & iType) at line 3 using color 15
- end ShowImageType
-
-
- on ShowFault(msg)
- display info gasInfoWind message msg at line 4 using color 12 * 1024
- pause for 120
- display info gasInfoWind message "…" at line 4
- end ShowFault
-
-
- on ShowAction(msg)
- display info gasInfoWind message msg at line 5
- end ShowAction
-
-
- on ShowError(errStr, errNum)
- display info gasInfoWind message "An error occured:" at line 6 using color (30 * 1024) using bg color 0
- display info gasInfoWind message (errStr) at line 7 using color (30 * 1024) using bg color 0
- display info gasInfoWind message "(Error number: " & errNum & ")" at line 8 using color (30 * 1024) using bg color 0
- beep
- pause for 180
- display info gasInfoWind message "The last error was:" at line 6
- end ShowError
-